package vip.xiaonuo.supplier.modular.warehouse.storeslocation.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import vip.xiaonuo.common.annotation.CommonLog;
import vip.xiaonuo.common.pojo.CommonResult;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.entity.SupplierStoresLocation;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.param.SupplierStoresLocationAddParam;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.param.SupplierStoresLocationEditParam;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.param.SupplierStoresLocationIdParam;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.param.SupplierStoresLocationPageParam;
import vip.xiaonuo.supplier.modular.warehouse.storeslocation.service.SupplierStoresLocationService;

import jakarta.annotation.Resource;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty;
import java.util.List;

/**
 * 库位信息控制器
 *
 * @author Mr.wu
 * @date  2025/03/15 21:29
 */
@Tag(name = "库位信息控制器")
@RestController
@Validated
public class SupplierStoresLocationController {

    @Resource
    private SupplierStoresLocationService supplierStoresLocationService;

    /**
     * 获取库位信息分页
     *
     * @author Mr.wu
     * @date  2025/03/15 21:29
     */
    @Operation(summary = "获取库位信息分页")
    @SaCheckPermission("/supplier/warehouse/storeslocation/page")
    @GetMapping("/supplier/warehouse/storeslocation/page")
    public CommonResult<Page<SupplierStoresLocation>> page(SupplierStoresLocationPageParam supplierStoresLocationPageParam) {
        return CommonResult.data(supplierStoresLocationService.page(supplierStoresLocationPageParam));
    }

    /**
     * 添加库位信息
     *
     * @author Mr.wu
     * @date  2025/03/15 21:29
     */
    @Operation(summary = "添加库位信息")
    @CommonLog("添加库位信息")
    @SaCheckPermission("/supplier/warehouse/storeslocation/add")
    @PostMapping("/supplier/warehouse/storeslocation/add")
    public CommonResult<String> add(@RequestBody @Valid SupplierStoresLocationAddParam supplierStoresLocationAddParam) {
        supplierStoresLocationService.add(supplierStoresLocationAddParam);
        return CommonResult.ok();
    }

    /**
     * 编辑库位信息
     *
     * @author Mr.wu
     * @date  2025/03/15 21:29
     */
    @Operation(summary = "编辑库位信息")
    @CommonLog("编辑库位信息")
    @SaCheckPermission("/supplier/warehouse/storeslocation/edit")
    @PostMapping("/supplier/warehouse/storeslocation/edit")
    public CommonResult<String> edit(@RequestBody @Valid SupplierStoresLocationEditParam supplierStoresLocationEditParam) {
        supplierStoresLocationService.edit(supplierStoresLocationEditParam);
        return CommonResult.ok();
    }

    /**
     * 删除库位信息
     *
     * @author Mr.wu
     * @date  2025/03/15 21:29
     */
    @Operation(summary = "删除库位信息")
    @CommonLog("删除库位信息")
    @SaCheckPermission("/supplier/warehouse/storeslocation/delete")
    @PostMapping("/supplier/warehouse/storeslocation/delete")
    public CommonResult<String> delete(@RequestBody @Valid @NotEmpty(message = "集合不能为空")
                                                   List<SupplierStoresLocationIdParam> supplierStoresLocationIdParamList) {
        supplierStoresLocationService.delete(supplierStoresLocationIdParamList);
        return CommonResult.ok();
    }

    /**
     * 获取库位信息详情
     *
     * @author Mr.wu
     * @date  2025/03/15 21:29
     */
    @Operation(summary = "获取库位信息详情")
    @SaCheckPermission("/supplier/warehouse/storeslocation/detail")
    @GetMapping("/supplier/warehouse/storeslocation/detail")
    public CommonResult<SupplierStoresLocation> detail(@Valid SupplierStoresLocationIdParam supplierStoresLocationIdParam) {
        return CommonResult.data(supplierStoresLocationService.detail(supplierStoresLocationIdParam));
    }
}
